package lesson2;

public class StopThread implements Runnable{

    @Override
    public void run() {
        int count = 0;
        while(!Thread.currentThread().isInterrupted() && count < 1000){
            System.out.println("count = " +  ++count);
            try {
                Thread.sleep(10000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) {
        StopThread stopThread = new StopThread();
        Thread thread = new Thread(stopThread);
        thread.start();
        try {
            Thread.sleep(5);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        thread.interrupt();
    }
}
